package commands;

import logic.UndoRedoManager;
import storage.Task;
import storage.TaskMemoryController;
import storage.UndoRedoDetails;

public class Remove {

	public String removeTask(int taskId) {

		Task task = TaskMemoryController.getTaskById(taskId);
		Task tempTask_ = new Task();
		tempTask_ = task;

		UndoRedoManager undoRedoManager = new UndoRedoManager();
		if (undoRedoManager.isNewCommand()) {
			UndoRedoDetails undoDetail_ = new UndoRedoDetails();
			undoDetail_.setDetails("remove", task.getId(), tempTask_, "", "", "");
			undoRedoManager.storeChanges(undoDetail_);
		}

		boolean removedSuccessfully = TaskMemoryController.removeTask(taskId);
		if (removedSuccessfully) {
			return "Task \"" + task.getTitle() + "\" removed.";
		} else {
			return "Remove is unsuccessful.";
		}
	}

}
